package LeetCode;

public class No206 {
    public ListNode reverseList(ListNode head) {
        ListNode curr = head;
        ListNode prv = null;
        while(curr!=null){
            ListNode temp = curr.next;
            curr.next = prv;
            prv = curr;
            curr = temp;
        }
        return head;
    }

    public ListNode reverseList1(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return newHead;
    }
}
